home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
findline.zip
/
FINDLINE.DOC
< prev
next >
Wrap
Text File
|
1992-12-13
|
4KB
|
110 lines
FINDLINE Scan file for text string; set errorlevel if found.
Copyright (c) 1992 Creativity in Action. All rights reserved.
SUMMARY
=======
FINDLINE scans a text file for a string of text. Unlike the DOS FIND command,
if the string is found in a line it sets an errorlevel flag. This flag can be
checked in a batch file.
SYNTAX
======
FINDLINE [/Help] [options] "search string" [d:][path]filename[.ext]
Where:
"search string" is the text string (in quotes) that you're
seeking, and
[d:][path]filename[.ext] specifies the file to be scanned, including
optional drive, path, and extension parameters.
Several switches are available:
/H Help. Displays basic help information.
/A All lines. Scan the entire file and count the number of lines with
matching strings. Unless this switch is set the program
will stop as soon as the first match is found.
/I Ignore case. Look for matches ignoring upper and lower case.
/L Line show. Displays the line that matches the search string. This
switch overrides the quiet mode switch.
/N Number show. Displays the line number associated with the matched
line. This switch works only if the /L switch is set.
/Q Quiet mode. Do not display messages. Useful in a batch file.
RETURN VALUES
=============
FINDLINE returns the following errorlevel codes
errorlevel meaning
---------- -------
0 string not found
1 string found in at least one line
2-250 string found 2-250 times (only valid if /a switch was set)
251 error opening input file
253-254 error reading input file
255 help was requested; string not sought
EXAMPLE
=======
You wish to scan a Windows .INI file to see if a string has already been
loaded.
For example, assume you want to automatically install a section called
[speaker.drv] to the SYSTEM.INI file, but only if it doesn't already exist.
You create a separate file called SPEAKER.INI containing the following lines:
[speaker.drv]
CPU Speed=71
Volume=500
Version=774
Enhanced=0
Max seconds=3
Leave interrupts enabled=0
In your auto-install batch file, include the following lines:
REM for this example, let's first get into our c:\windows directory
c:
cd \windows
REM FINDLINE will set errorlevel to 1 or greater if [speaker.drv] was found
REM /i to ignore case, /q since we don't want to watch FINDLINE work
FINDLINE "[speaker.drv]" system.ini /i /q
IF ERRORLEVEL 1 GOTO found
REM not found, so concatenate the speaker.ini file to the system.ini
echo Updating SYSTEM.INI ....
copy system.ini+speaker.ini > nul
goto done
:found
echo SYSTEM.INI already contains reference to [speaker.drv]
:done
echo Done ....
SHAREWARE
=========
This program was written as shareware; your comments are welcome. However, we
reserve the copyright for the program. If you find FINDLINE useful, send a
few bucks to
Creativity in Action, P. O. Box 6026, Fullerton, CA 92634-6026.
You're welcome--nay, encouraged--to distribute the program as long as you
don't charge anything for it and don't change it in any way. Be sure to
include the documentation file when you distribute it. You corporate guys--
send a few extra bucks if you're going to use it all over the place.
Thanks for your support ....
HISTORY
=======
Version 0.90 Initial (beta) version
Version 1.00 First release; added support of backslashes and hyphens for
switches; truncate switches to first two characters (virgule
plus letter); added several switches; reversed filename/
searchstring order for greater consistency with DR DOS and MS
DOS FIND command; changed some switch names, added others,
again for FIND consistency; added errorlevel codes for file
access errors.